<template>
  <view class="items">
    <view class="title">{{ subtitle }}</view>
    <view class="btn">
      <view @click="getdata(1)" :class="number == 1 ? 'box1' : ''">草 稿</view>
      <view @click="getdata(2)" :class="number == 2 ? 'box1' : ''">记 录</view>
      <view @click="goadd">新 增</view>
    </view>
    <view v-for="(item, i) of list" :key="i" class="item" @click="gocg(item)">
      <view class="content">
        <view class="titleflex">
          <view class="worktitle">
            <view v-for="word of item.title" :key="word">{{ word }}</view>
          </view>
          <view class="zt" v-if="number == 2">
            <text v-if="item.flowstatus == 1" style="color: #de7b24"
              >审核中</text
            >
            <text v-if="item.flowstatus == 2" style="color: #85b585"
              >审核通过</text
            >
            <text v-if="item.flowstatus == 3" style="color: #ea961a"
              >审核不通过</text
            >
            <text v-if="item.flowstatus == 5" style="color: #9fa0a0"
              >验收完成</text
            >
          </view>
          <view class="zt" v-else>
            <view>草稿</view>
          </view>
        </view>
        <!-- <view class="zt" v-else>废弃表单</view> -->
      </view>
      <view class="work2">
        <view>
          <text>创建人: </text>
          <text>{{ item.createUsername }}</text>
        </view>
      </view>
      <view class="work">
        <view>
          <text>创建时间: </text>
        </view>
        <view>
          <text>{{ item.createDate || "" }}</text>
        </view>
      </view>
      <view class="work" v-if="item.acceptanceEnd">
        <view>
          <text>完工时间: </text>
        </view>
        <view>
          <text>{{ item.acceptanceEnd || "" }}</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
//import uniDataCheckbox1 from "@/components/uni-data-checkbox/uni-data-checkbox1.vue";
//import { templateMixin } from "../../../../libs/core";
export default {
  // components: { uniDataCheckbox1 },
  props: {
    projectId: {
      type: String,
      defult: "",
    },
    categoryId: {
      type: String,
    },
    subtitle: {
      type: String,
    },
    userId: {},
    onshowNumber: {},
  },
 // mixins: [templateMixin],
  data() {
    return {
      list: [],
      number: 2,
    };
  },
  mounted() {
    this.getdata();
  },
  methods: {
    async getdata(i = 2) {
      this.number = i;
      const { data } = await this.post(
        "/engineer-item/item/licenceUser/control/LicenceControlDistinguishlist",
        {
          categoryId: this.categoryId,
          projectId: this.projectId,
          savestatus: i,
          flowstatus: "",
        }
      );
      this.list = data;
    },
    gocg(item) {
      const categoryId = item.categoryId;
      if (categoryId == 4) {
        this.$router.navigateTo({
          url: `/engineer/workTicket/hotWork/index?licenceControlId=${item.id}&showtype=${this.number}&userId=${this.userId}&title=${this.subtitle}`,
        });
      } else if (
        categoryId == 1 ||
        categoryId == 2 ||
        categoryId == 3 ||
        categoryId == 5 ||
        categoryId == 7 ||
        categoryId == 8 ||
        categoryId == 9
      ) {
        this.$router.navigateTo({
          url: `/engineer/workTicket/templateWork/index?licenceControlId=${item.id}&showtype=${this.number}&userId=${this.userId}&categoryId=${categoryId}&title=${this.subtitle}`,
        });
      } else if (categoryId == 6) {
        this.$router.navigateTo({
          url: `/engineer/workTicket/finiteSpace/index?licenceControlId=${item.id}&showtype=${this.number}&userId=${this.userId}&categoryId=${categoryId}&title=${this.subtitle}`,
        });
      }
    },
    goadd() {
      const itemid = this.categoryId;
      if (itemid == 4) {
        this.$router.navigateTo({
          url: `/engineer/workTicket/hotWork/index?itemid=${itemid}&title=${this.subtitle}`,
        });
      } else if (
        itemid == 1 ||
        itemid == 2 ||
        itemid == 3 ||
        itemid == 5 ||
        itemid == 7 ||
        itemid == 8 ||
        itemid == 9
      ) {
        this.$router.navigateTo({
          url: `/engineer/workTicket/templateWork/index?itemId=${itemid}&title=${this.subtitle}`,
        });
      } else if (itemid == 6) {
        this.$router.navigateTo({
          url: `/engineer/workTicket/finiteSpace/index?itemId=${itemid}&title=${this.subtitle}`,
        });
      }
    },
  },
  watch: {
    projectId() {
      this.getdata();
    },
    categoryId() {
      this.getdata();
    },
    onshowNumber() {
      this.getdata();
    },
  },
};
</script>

<style scoped lang="scss">
.items {
  width: 90%;
  margin: 0 auto;
  position: relative;
  padding-bottom: 85rpx;
  font-size: 0.8rem;
  font-family: Source Han Sans CN;
  font-weight: 500;
  color: #595757;
}
.title {
  width: 100%;
  color: #fefefe;
  text-align: center;
  padding: 21rpx 0;
  background: #dde7f8;
}
.item {
  margin-top: 35rpx;
  border-radius: 15rpx;
  padding: 15rpx;
  border-bottom: 1rpx solid #dedede;
}
.work,
.work2 {
  display: flex;
  justify-content: space-between;
  margin: 15rpx 0;
  color: #9fa0a0;
  font-size: 0.8rem;
}
.work2 {
  color: #595757;
}
.content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
}
.titleflex {
  width: 100%;
  display: flex;
}
.worktitle {
  width: 72%;
  display: flex;
  flex-wrap: wrap;
  font-size: 0.82rem;
  font-weight: 600;
}
.zt {
  width: 26%;
  text-align: right;
  font-size: 0.7rem;
}
.btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2vh;
  background: #fff;
  view {
    width: 33%;
    text-align: center;
    height: 5vh;
    border-radius: 9rpx;
    line-height: 5vh;
  }
  .box1 {
    background: #2f66c0;
    color: #fff;
    font-weight: bold;
  }
}
</style>